﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
//using FOBVT.Web.MainClass;

namespace FOBVT.Web.FOBVT2011.en
{
    public partial class login : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void btnLogin_Click(object sender, EventArgs e)
        {
            System.Data.OleDb.OleDbConnection Conn = new System.Data.OleDb.OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + Server.MapPath("..\\..\\DB\\FOBVTweb.mdb"));

            MainClass.GetUserInfo userInfoClass = new MainClass.GetUserInfo();
            userInfoClass.Conn = Conn;
            userInfoClass.Email = txtEmail.Text.Trim();
            userInfoClass.Password = FOBVT.Web.MainClass.DEncrypt.Encrypt(txtPassword.Text.Trim());

            FOBVT.Web.MainClass.User result = userInfoClass.UserLogin();

            if (result != null)
            {
                FOBVT.Web.MainClass.SessionState.CurrentUser = result;


                switch (FOBVT.Web.MainClass.SessionState.CurrentUser.Email)
                { 
                    case "admin@fobtv2011.org":
                        Response.Redirect("CustomerList.aspx");
                        break;
                    case "test@fobtv2011.org":
                        Response.Redirect("RegistrationFee.aspx");
                        break;
                    default:
                        Response.Redirect("RegistarationComplete.aspx");
                        break;
                
                }
                if (FOBVT.Web.MainClass.SessionState.CurrentUser.Email != "admin@fobtv2011.org")
                {
                   // Response.Redirect("RegistarationComplete.aspx");
                }
                else
                {
                    Response.Redirect("RegistrationFee.aspx");
                }
            }
            else
            {
                FOBVT.Web.MainClass.WebMessageBox.Show(this, "Logon failed！");
            }
        }
    }
}